import {ajax} from './util.js';

let btns = document.querySelector('#btn');
let username = document.querySelector('#username');
let pwd = document.querySelector('#pwd');
let tip = document.querySelector('.tip');

btns.onclick = function(){
    ajax.post('/login',{username:username.value,pwd:pwd.value},function(data){
        console.log(data);
        if(data.code===200){
            //登录成功
            window.location.href = '/list';
        }else{
            // 账号或密码错误
            tip.innerHTML = data.msg;
        }
    })
}

